//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uType:"",
    makerId:"",
    pagemodal: true,
    pageIndex: 1,
    businessList: [],
    state:"",
    // 
    uid:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      makerId: wx.getStorageSync('uid'),
      uType: options.uType,
    })
    this.GetPartnerBusinessList();
  },


  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.data.pageIndex++;
    this.GetPartnerBusinessList();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  },

  // GetPartnerBusinessList
  GetPartnerBusinessList:function(){
    var that = this;
    var uid = this.data.uid;
    var uType = this.data.uType;
    var makerId = this.data.makerId;
    var pageIndex = this.data.pageIndex;
    var businessList = this.data.businessList;
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=GetPartnerBusinessList&PageSize=10&PageIndex=" + pageIndex + "&UID=" + makerId + "&UType=" + uType),
      success: function (res) {
        console.log("method=GetPartnerBusinessList&PageSize=10&PageIndex=" + pageIndex + "&UID=" + makerId + "&UType=" + uType);
        var json = JSON.parse(baseJs.decryUrl(res.data)).ResultData;
        console.log(json);
        for (var i = 0; i < json.length; i++) {
          businessList.push(json[i])
        }
        that.setData({
          businessList: businessList
        })
        if (json.length == 10) {
          that.setData({
            state: 'loadMore',
          })
        } else if (json.length == 0 && pageIndex == 1) {
          that.setData({
            state: 'noData',
          })
        } else if (json.length < 10) {
          that.setData({
            state: 'noMore',
          })
        } else if (json.length == 0 && pageIndex > 1) {
          that.setData({
            state: 'noMore',
          })
        }
      }
    })
  },
  // 
})